From: Boris Ostrovsky Date: Thu, 26 Feb 2015 13:08:34 +0000 (+0100) Subject: mm: MEMF_node should handle changes in nodeid_t size X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3711 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=befe0a0da90d7ac063fd8b5891c7d0caeeeefa5f;p=xen.git mm: MEMF_node should handle changes in nodeid_t size Instead of using a hardcoded constant to extract nodeID from memflags use a macro whose value is based on nodeid_t size. Also provide a macro for extracting nodeID from memflags so that users don't need to remember to decrement the value. Signed-off-by: Boris Ostrovsky MASK_EXTR() can't be used in MEMF2NODE() (also renamed to MEMF_get_node()). Signed-off-by: Jan Beulich --- diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 6bd3b7526d..d96d25bc14 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -581,13 +581,16 @@ static struct page_info *alloc_heap_pages( struct domain *d) { unsigned int i, j, zone = 0, nodemask_retry = 0; - nodeid_t first_node, node = (nodeid_t)((memflags >> _MEMF_node) - 1); + nodeid_t first_node, node = MEMF_get_node(memflags); unsigned long request = 1UL << order; struct page_info *pg; nodemask_t nodemask = (d != NULL ) ? d->node_affinity : node_online_map; bool_t need_tlbflush = 0; uint32_t tlbflush_timestamp = 0; + /* Make sure there are enough bits in memflags for nodeID. */ + BUILD_BUG_ON((_MEMF_bits - _MEMF_node) < (8 * sizeof(nodeid_t))); + if ( node == NUMA_NO_NODE ) { memflags &= ~MEMF_exact_node; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index a62ee1e3ae..6ea8b8cbd4 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -121,7 +121,9 @@ struct npfec { #define _MEMF_exact_node 4 #define MEMF_exact_node (1U<<_MEMF_exact_node) #define _MEMF_node 8 -#define MEMF_node(n) ((((n)+1)&0xff)<<_MEMF_node) +#define MEMF_node_mask ((1U << (8 * sizeof(nodeid_t))) - 1) +#define MEMF_node(n) ((((n) + 1) & MEMF_node_mask) << _MEMF_node) +#define MEMF_get_node(f) ((((f) >> _MEMF_node) - 1) & MEMF_node_mask) #define _MEMF_bits 24 #define MEMF_bits(n) ((n)<<_MEMF_bits)